<%--
  - Author		:	Jaewon Choi
  - Date			:
  - Description	:	
  --%>
<%@ page language="java" %>
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/pages/includes/taglibs.jspf" %>
<%@ include file="/WEB-INF/pages/includes/variables.jspf" %>
<%@ include file="/WEB-INF/pages/includes/doctype.jspf" %>
<html>
	<head>
<%@ include file="/WEB-INF/pages/includes/metatags.jspf" %>
		<title><fmt:message key="pages.title" /></title>
		<link rel="stylesheet" type="text/css" href="<c:url value="${dirStyles}/common.css" />" />
		<link rel="stylesheet" type="text/css" href="<c:url value="${dirScripts}/jqueryUi/css/ui-lightness/jquery-ui-1.8.21.custom.css" />" />

		<script type="text/javascript" src="<c:url value="${dirScripts}/common.js" />"></script>
		<script type="text/javascript" src="<c:url value="${dirScripts}/jquery-1.7.2.min.js" />"></script>
		<script type="text/javascript" src="<c:url value="${dirScripts}/jquery-ui-1.8.21.custom.min.js" />"></script>
		<script type="text/javascript">
			$(function() {
				$( ".date" ).datepicker({
					showOn: "both",
					buttonImage: "<c:url value="${dirImages}/calendar.png" />",
					buttonImageOnly: true,
					dateFormat: "yy-mm-dd"
				});
			});
			function goAction(idx){
				if(idx == "" || ! idx){
					return false;
				}
				document.frm.idx.value= idx;
				document.frm.submit();
			}
			
			function goPage(page){
				document.searchFrm.page.value = page;
				document.searchFrm.submit();
			}

		</script>
	</head>
	<body>
		<div class="bodyWrap">
<%@ include file="/WEB-INF/pages/includes/header.jsp" %>
<%@ include file="/WEB-INF/pages/includes/left.jsp" %>
			<div class="contWrap">
				<div class="menuTitle">Android푸시메시지목록</div>
				<div class="searchWrap">
					<form name="searchFrm" action="<c:url value="/gcm/list.do" />" method="post">
						<input type="hidden" name="maxnum" value="${maxnum}" />
						<input type="hidden" name="page" value="${page}" />
						<ul  class="lineBlock">
							<li>
								<font style="width: 50px;">기간</font>
								<input type="checkbox" name="searchDate" value="1" onclick="javascript:$('.date').attr('disabled', !this.checked);" <c:if test="${param.searchDate eq 1}"> checked="checked" </c:if>>
								<input type="text" class="date" name="beginTime" readonly="readonly" value="${param.beginTime}" <c:if test="${param.searchDate ne 1}"> disabled="disabled" </c:if> /> ~ <input type="text" class="date" name="endTime" readonly="readonly" value="${param.endTime}" <c:if test="${param.searchDate ne 1}"> disabled="disabled" </c:if> />
								<span style="float:right;">
									<input class="btn" type="submit" value="조회" onclick="javascript:document.searchFrm.page.value=1;" />
								</span>
							</li>
						</ul>
					</form>
					<div style="text-align: right;">
						<input type="button" class="btn" value="등록" onclick="javascript:location.href='<c:url value="/gcm/form.do" />';" />
					</div>
				</div>
				<form name="removeFrm" method="post" action="<c:url value="/gcm/remove.do" />">
					<input type="hidden" name="maxnum" value="${maxnum}" />
					<input type="hidden" name="page" value="${page}" />
					<input type="hidden" name="searchDate" value="${param.searchDate}">
					<input type="hidden" name="beginTime" value="${param.beginTime}" /> 
					<input type="hidden" name="endTime" value="${param.endTime}" />
					<input type="hidden" name="fAct" value="remove">
					<table class="listTbl">
						<colgroup>
							<col width="35px;" />
							<col width="35px;" />
							<col width="*" />
							<col width="50px" />
							<col width="50px" />
							<col width="120px" />
							<col width="80px" />
							<col width="80px" />
							<col width="60px" />
						</colgroup>
						<thead>
							<tr>
								<th><input type="checkbox" onclick="javascript:$('.removeChk').attr('checked', $(this).is(':checked')?true:false);"></th>
								<th>No.</th>
								<th>제목</th>
								<th>성공수</th>
								<th>실패수</th>
								<th>발송일시</th>
								<th>등록일시</th>
								<th>최종수정일시</th>
								<th>상태</th>
							</tr>
						</thead>
						<c:choose>
							<c:when test="${gcmListTotalCnt ne 0}">
								<tbody>
									<c:forEach items="${gcmList}" var="gcm" varStatus="gcmStat">
										<tr class="dataTr">
											<td>
												<input type="checkbox" name="idx" class="removeChk" value="${gcm.idx}">
											</td>
											<td>${gcmListTotalCnt - gcmStat.index - (maxnum*(page-1))}</td>
											<td onclick="javascript:goAction(${gcm.idx});" style="text-align: left; text-indent: 15px;">
												<c:choose>
													<c:when test="${fn:length(gcm.title) > 22}">
														<c:out value="${fn:substring(gcm.title, 0, 22)}" />...
													</c:when>
													<c:otherwise>
														<c:out value="${gcm.title}" />
													</c:otherwise>
												</c:choose>
											</td>
											<td onclick="javascript:goAction(${gcm.idx});" style="text-align: left; text-indent: 15px;">
												<c:out value="${gcm.successCnt}" />
											</td>
											<td onclick="javascript:goAction(${gcm.idx});" style="text-align: left; text-indent: 15px;">
												<c:out value="${gcm.failureCnt}" />
											</td>
											<td onclick="javascript:goAction(${gcm.idx});">
												<c:catch var="e">
													<fmt:parseDate var="sendTime" pattern="yyyy-MM-dd HH:mm:ss" value="${gcm.sendTime}" />
													<fmt:formatDate value="${sendTime}" pattern="yyyy-MM-dd HH:mm:ss" />
												</c:catch>
												<c:if test="${not empty e}">
													${gcm.sendTime}
												</c:if>
											</td>
											<td onclick="javascript:goAction(${gcm.idx});">
												<c:catch var="e">
													<fmt:parseDate var="createdTime" pattern="yyyy-MM-dd HH:mm:ss" value="${gcm.createdTime}" />
													<fmt:formatDate value="${createdTime}" pattern="yyyy-MM-dd" />
												</c:catch>
												<c:if test="${not empty e}">
													${gcm.createdTime}
												</c:if>
											</td>
											<td onclick="javascript:goAction(${gcm.idx});">
												<c:catch var="e">
													<fmt:parseDate var="modifiedTime" pattern="yyyy-MM-dd HH:mm:ss" value="${gcm.modifiedTime}" />
													<fmt:formatDate value="${modifiedTime}" pattern="yyyy-MM-dd" />
												</c:catch>
												<c:if test="${not empty e}">
													${gcm.modifiedTime}
												</c:if>
											</td>
											<td>
												<c:choose>
													<c:when test="${gcm.status eq -1}">발송실패</c:when>
													<c:when test="${gcm.status eq 0}">발송준비</c:when>
													<c:when test="${gcm.status eq 1}">발송대기</c:when>
													<c:when test="${gcm.status eq 2}">발송완료</c:when>
													<c:otherwise>
														${gcm.status}
													</c:otherwise>
												</c:choose>
											</td>
										</tr>
									</c:forEach>
								</tbody>
							</c:when>
							<c:otherwise>
								<tfoot>
									<tr><td colspan="9" style="text-align: center;">데이터가 없습니다.</td></tr>
								</tfoot>
							</c:otherwise>
						</c:choose>
					</table>
					<c:if test="${gcmListTotalCnt ne 0}">
						<div class="pagingWrap">
							<jsp:include page="/WEB-INF/pages/includes/paging.jsp">
								<jsp:param name="totalNum" value="${gcmListTotalCnt}" />
								<jsp:param name="pageListCnt" value="${maxnum}" />
								<jsp:param name="pageGrpCnt" value="5" />
								<jsp:param name="pageIdx" value="${page}" />
							</jsp:include>
						</div>
					</c:if>
					<input type="button" class="btn" value="삭제" onclick="javascript:if(confirm('선택하신 목록을 삭제하시겠습니까?')){document.removeFrm.submit();}" />
					<input type="button" class="btn" value="등록" onclick="javascript:location.href='<c:url value="/gcm/form.do" />';" />
				</form>
				<form name="frm" action="<c:url value="/gcm/detail.do" />" method="post" style="display: none;">
					<input type="hidden" name="idx" value="">
					<input type="hidden" name="maxnum" value="${maxnum}" />
					<input type="hidden" name="page" value="${page}" />
					<input type="hidden" name="searchDate" value="${param.searchDate}">
					<input type="hidden" name="searchBeginTime" value="${param.beginTime}" /> 
					<input type="hidden" name="searchEndTime" value="${param.endTime}" />
				</form>
			</div>
<%@ include file="/WEB-INF/pages/includes/footer.jsp" %>
		</div>
	</body>
</html> 